import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '@/views/Home.vue'
import VoteGame from '@/views/VoteGame.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      title: '泡泡舞会'
    }
  },
  {
    path: '/bubble-game',
    name: 'BubbleGame',
    component: Home,
    meta: {
      title: '泡泡舞会'
    }
  },
  {
    path: '/vote-game',
    name: 'VoteGame',
    component: VoteGame,
    meta: {
      title: '投票游戏'
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta.title) {
    document.title = `${to.meta.title} - Vue3 Setup 项目`
  }
  console.log('路由跳转:', to.path, '完整URL:', window.location.href)
  next()
})

export default router
